﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2020._11._19
{
    class Program
    {
        static void Main(string[] args)
        {
            List<int> ls = new List<int>();
            List<Students> stus = new List<Students>();

            Random rnd = new Random();

            for (int i = 0; i < 20; i++)
            {
                var temp = new Students
                {
                    Id = rnd.Next(1, 100),
                    Name = "SoftLiPApa" + rnd.Next(1, 100),
                    Sex = rnd.Next(0, 2) > 0 ? "男":"女",
                    Height = rnd.Next(150, 240),
                    Age = rnd.Next(15,25)
                };
                stus.Add(temp);
            }
            stus.PrintInfo();

            Query(stus, x => x.Age > 18 && x.Height > 180);

            stus.SoftLiPApa(x => x.Age > 18 && x.Height > 180).SoftLiPApa(x => x.Sex == "男").PrintInfo();
            stus.Where(t => t.Age > 18 && t.Height > 180).Where(o => o.Sex == "男").PrintInfo();

            Query(ls,180).PrintInfo();

            Console.ReadLine();
        }

        static List<int> Query(List<int>ls,int x)
        {
            List<int> newList = new List<int>();

            foreach(var item in ls)
            {
                if(item > x)
                {
                    newList.Add(item);
                }
            }
            return newList;
        }
        static List<Students> Query(List<Students> ls, Func<Students, bool> func)
        {
            List<Students> newList = new List<Students>();
            foreach(var item in ls)
            {
                if (func(item))
                {
                    newList.Add(item);
                }
            }
            return newList;
        }
        public static bool Judge(Students stu)
        {
            return stu.Age > 18 && stu.Height > 180 && stu.Sex == "男";
        }
    }
}
